import {ListItemCache} from "obsidian";

export class ListItem {
    id: number;
    parentId: number;
    children: ListItem[];

    startLine: number;
    startOffset: number;
    endLine: number;
    endOffset: number;

    text: string;
    level: number;

    constructor(listItemCache: ListItemCache, text: string = null) {
        this.id = listItemCache.position.start.line;
        if (listItemCache.parent >= 0) {
            this.parentId = listItemCache.parent;
        } else {
            this.parentId = null;
        }
        this.children = [];
        this.startLine = listItemCache.position.start.line;
        this.startOffset = listItemCache.position.start.offset;
        this.endLine = listItemCache.position.end.line;
        this.endOffset = listItemCache.position.end.offset;

        this.text = text;
    }

    // toText222(): string {
    //    return "\t".repeat(this.level) + this.text;
    // }
}